package com.weimai.message.gateway.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weimai.message.gateway.entity.GwUserAccess;
import com.weimai.message.gateway.service.GwUserAccessService;
import com.weimai.message.gateway.mapper.GwUserAccessMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;


/**
 *  表数据服务层接口实现类
 * @author geer
 */
@Service
@Slf4j
public class GwUserAccessServiceImpl extends ServiceImpl<GwUserAccessMapper, GwUserAccess> implements GwUserAccessService {
    
    @Cacheable(value = "msgGateway:accessKey",key = "#accessKey")
    @Override
    public String getByAccessSecret(String accessKey) {
        QueryWrapper<GwUserAccess> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(GwUserAccess::getAccessKey, accessKey);
        
        GwUserAccess result = super.getOne(queryWrapper);
       
        if (result != null){
            return result.getAccessSecret();
        }
        
        return null;
    }
}
